package com.esir.harmony.base;


import com.esir.harmony.base.mvp.IBasePresenter;
import com.esir.harmony.base.mvp.IBaseView;
import ohos.aafwk.content.Intent;

/**
 * @author 黄嵘才(HuangRc)
 */
public abstract class BaseMvpAbility<P extends IBasePresenter> extends BaseAbility
        implements IBaseView {

    protected P mPresenter;

    protected P presenter() {
        return mPresenter;
    }

    @Override
    protected void initView() {

    }

    @Override
    public ContextX getContextX() {
        return new ContentXWrapper(this);
    }

    @Override
    public void showMsg(Object tag, String msg) {
        //TOAST
    }

    @Override
    protected void onStart(Intent intent) {
        super.onStart(intent);
        //创建present
        mPresenter = createPresenter();
        if (mPresenter != null) {
            mPresenter.attachView(this);
        }
    }

    @Override
    protected void onStop() {
        super.onStop();
        if (mPresenter != null) {
            mPresenter.detachView(this);
        }
    }

    /**
     * 创建Presenter
     */
    protected abstract P createPresenter();
}
